<?php
if(isset($_POST['out']))
{	
	$mess="已退出";
	header("location:login.php?mess=$mess");
}
if(isset($_POST['reg']))
{
	header("location:register.php");
}
if(isset($_POST['log']))
{
	header("location:login.php");
}
$uid=$_GET['uid'];
include_once 'mysql_connect.php';
$NOW_time=date("ag:i:s",time());	
$NOW_week=date("l",time());	

$member=mysql_query(" SELECT * FROM `member` WHERE `uid`=$uid ");
$member=mysql_fetch_array($member);
$userface=$member['userface'];
$username=$member['username'];
$sex=$member['sex'];
switch($sex)
{
	case 1: $sex="男生"; break;
	case 2: $sex="女生"; break;
	case 3: $sex="男"; break;
	case 4: $sex="女"; break;
}

/**************字体颜色****************/
$rand=rand(1,6);
switch($rand)
{
	case 1: $fontcolor="#000000"; break;
	case 2: $fontcolor="#00FF00"; break;
	case 3: $fontcolor="#0000FF"; break;
	case 4: $fontcolor="#00FFFF"; break;
	case 5: $fontcolor="#CCFF00"; break;
	case 6: $fontcolor="#FF0000"; break;
	default: $fontcolor="#000000"; break;
}

/**************心情数量****************/
$mood_num=mysql_query(" SELECT `uid` FROM `mood` WHERE `uid`='$uid' ");
$mood_num=mysql_num_rows($mood_num)+1;

/**************写心情****************/
if(isset( $_POST['post_mood']) && !empty($_POST['say_mood']) )
{
	$time=time();
	$say_mood=$_POST['say_mood'];
	$father_id=mysql_query(" SELECT `tid` FROM `mood` ORDER BY `tid` DESC ");
	$father_id=mysql_fetch_array($father_id);
	$father_id=$father_id['tid']+1;
	mysql_query(" INSERT INTO `mood` (`fontcolor`, `uid`, `father_id`, `post_mood`, `dateline`, `userface`, `comment_num`) VALUES ('$fontcolor', '$uid', '$father_id', '$say_mood', '$time', '$userface', '0') ");
}
if(isset( $_POST['r_submit']) && !empty($_POST['r_mood']) )
{
	$fuid=explode(',' ,$_GET['fuid']);
	echo $uid=$fuid['0'];
	echo $fid=$fuid['1'];
	$time=time();
	$r_mood=$_POST['r_mood'];
	$userface='photo/userface.jpg';
	$father_id=mysql_query(" SELECT `tid` FROM `mood` ORDER BY `tid` DESC ");
	$father_id=mysql_fetch_array($father_id);
	$father_id=$father_id['tid']+1;
	mysql_query(" INSERT INTO `mood` (`fontcolor`, `uid`, `father_id`, `post_mood`, `dateline`, `userface`, `comment_num`) VALUES ('$fontcolor', '$uid', '$father_id', '$say_mood', '$time', '$userface', '0') ");
}

$csubmit=$_POST['csubmit'];
$uid=$_GET['uid'];
if($csubmit=='修改密码')
{	
	$message="$uid,password";
	header("location:show.php?change_infor=$message");
}
if($csubmit=='修改昵称')
{
	$message="$uid,username";
	header("location:show.php?change_infor=$message");
}
if($csubmit=='重置头像')
{
	$message="$uid,headimg";
	header("location:show.php?change_infor=$message");
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $username; ?>&nbsp;的空间</title>
</head>

<body>

<form action="user_zone.php" method="post">
<input type="submit" name="out" value="退出" />
<input type="submit" name="reg" value="注册" />
<input type="submit" name="log" value="登录" />
</form>
&nbsp;
<hr />

<form action="user_zone.php?uid=<?php echo $uid ;?>" method="post">

<input type="submit" name="csubmit" value="修改密码"/>
<input type="submit" name="csubmit" value="修改昵称" />
<input type="submit" name="csubmit" value="重置头像" />
<hr />
	
<table width="80%" height="100" align="center" border="1"  bordercolor="#00FF99">
	<tr>
	
	  <td width="100" height="73">
		<img src="<?php echo $userface ;?>" height="100" width="100" /><br />
	  </td>
		 
	  <td width="112" valign="middle">
		 <font color="<?php echo $fontcolor ;?>"><?php echo $username ; ?></font><br />
		 <font color="<?php echo $fontcolor ;?>"><?php echo $sex ; ?></font><br />
		 <font color="<?php echo $fontcolor ;?>"><?php echo $NOW_week ; ?></font><br />
		 <font color="<?php echo $fontcolor ;?>"><?php echo $NOW_time ; ?></font><br />
	  </td>
		 
	  <td colspan="3" valign="top">
		  <textarea name="say_mood" cols="50" rows="4">说说你今天的心情吧~！</textarea><br />
		  <input type="submit" name="post_mood" value="发表第<?php echo $mood_num ;?>次心情" />
	 </td>	
	 	  
	</tr>
</table>
</form>	  
<?php 
$mood_query=mysql_query(" SELECT * FROM `mood` WHERE `uid`='$uid' ORDER BY `tid` DESC ");
while($row=mysql_fetch_array($mood_query))
{  
	$fontcolor=$row['fontcolor'];
	$post_mood=$row['post_mood'];//发表心情
	$p_dateline=$row['dateline'];//发表心情时间
	$p_dateline=date("G:i:s ",$p_dateline);
	$father_id=$row['father_id'];
	

	
?>
<table width="80%" align="center" border="1" bordercolor="#00FF00">

	<tr>	
	
  		<td width="12" height="10" colspan="4">
			<img src="<?php echo $userface;?>" width="40" height="40" />
			<font color="red"><?php echo $username ;?>&nbsp;</font>
			<font color="<?php echo $fontcolor ;?>"><?php echo $p_dateline?></font>			
		</td>	
		

	  <td height="52" colspan="5">
	  	<font color="<?php echo $fontcolor ; ?>"><?php echo $post_mood ; ?></font>
	  </td>
	
<?php
}
?>

</form>
</body>
</html>
